package com.bupt.chapter.third.max_distance_in_binary_tree;

public class Solution {
	public static void main(String[] args) {

	}

	public static int getMax(TreeNode node) {
		int distance = 0;
		if(node!=null){
			distance = getDepth(node.left)+getDepth(node.right);
			int l = getMax(node.left);
			int r = getMax(node.right);
			distance = Math.max(Math.max(l, r), distance);
		}
		return distance;
	}

	public static int getDepth(TreeNode node) {
		int depth = 0;
		if (node != null) {
			int a = getDepth(node.left);
			int b = getDepth(node.right);
			depth = Math.max(a, b);
			depth++;
		}
		return depth;
	}
}
